package com.itstyle.seckill.du.inter;

import org.redisson.api.RLock;

import java.util.concurrent.TimeUnit;

/**
 * @author duzining
 */
public interface RedissonLocker {

    /**
     * lock String lockKey
     * @param lockKey
     * @return
     */
    RLock lock(String lockKey);

    /**
     * lock String lockKey long timeout
     * @param lockKey
     * @param timeout
     * @return
     */
    RLock lock(String lockKey,long timeout);


    /**
     * lock String lockKey TimeUnit unit
     * @param lockKey
     * @param unit
     * @param timeout
     * @return
     */
    RLock lock(String lockKey, TimeUnit unit,long timeout);

    /**
     * tryLock string lockKey TimeUnit unit long waitTime long leaseTime
     * @param lockKey
     * @param unit
     * @param waitTime
     * @param leaseTime
     * @return
     */
    boolean tryLock(String lockKey,TimeUnit unit,long waitTime,long leaseTime);

    /**
     * unlock String lockKey
     * @param lockKey
     */
    void unlock(String lockKey);

    /**
     * unlock RLock lock
     * @param lock
     */
    void unlock(RLock lock);

}
